<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文章列表--layui后台管理模板</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="../../js/layui/css/layui.css"
	media="all" />
<script src="../../js/layui/layui.js"></script>
<link rel="stylesheet" href="../../css/font_eolqem241z66flxr.css"
	media="all" />
<link rel="stylesheet" href="../../css/news.css" media="all" />

<style type="text/css">
.layui-table-cell {
	text-align: center;
	height: auto;
	white-space: normal;
	width : auto,
}
</style>
</head>
<body class="childrenBody">
	<blockquote class="layui-elem-quote news_search">
		<form class="layui-form" method="post" onsubmit="return false;">
			<label class="layui-form-mid">活动标题:</label>
			<div class="layui-input-inline">
				<input type="text" id="name" name="name" placeholder="请输入活动标题"
					autocomplete="off" class="layui-input  search_input">
			</div>

			<div class="layui-input-inline" style="width: 100px;">
				<button class="layui-btn" id="search" data-type="reload">搜索</button>

			</div>
			<div class="layui-inline">
				<a class="layui-btn linksAdd_btn" style="background-color: #5FB878">添加活动</a>
			</div>
			
		</form>


	</blockquote>
	<div class="layui-form links_list">
		<table class="layui-table" id="deigner" lay-filter="table">

		</table>
	</div>

	<!-- <div id="page"></div> -->
	<script type="text/html" id="barDemo">
			
			<a class="layui-btn layui-btn-sm" lay-event="edit" ><i class="layui-icon layui-icon-edit"></i>编辑</a>
			<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
		</script>
	<script type="text/javascript">
		layui.use([ 'table', 'layer' ], function() {
			var table = layui.table, $ = layui.$, layer = layui.layer;
			table.render({
				elem : '#deigner',
				url : 'http://localhost:8080/DogHome/sinfoServlet?md=getlimitNewsinfos' 
				,
				page:true,
				limit:3,
				limits:[3,4,5],
				cols : [ [ 
				
				{
					field : 'newsinfoid',
					title : '编号',
					width : 50
				},{
					field : 'newsinfoname',
					title : '负责人',
					width : 100
				},  {
					field : 'mewsinfotime',
					title : '时间',
					width : 150
				}, {
					field : 'newsinfotext',
					title : '内容',
					width : 200
				},{
					field : 'newsinfoimg',
					title : '图片',
					width : 200,
					templet : '<div><img src="../../../{{d.newsinfoimg}}" /></div>'
				},{
					field : 'newsinfotale',
					title : '培训典故',
					width : 150
				}, {
					title : '操作',
					align : 'center',
					fixed : 'right',
					width : 200,
					toolbar : '#barDemo'
				}

				] ],
				id : "DesignerReload"
			});
			$("#search")
			.click(
					function() {
						table
								.reload(
										'DesignerReload',
										{
											url : 'http://localhost:8080/DogHome/sinfoServlet?md=getWhereNewsinfos',
											page : {
												curr : 1
											},
											where : {
												name : $(
														"#name")
														.val()
											}
										});
					});
			table.on('tool(table)', function(obj) {
				var data = obj.data; 
				var layEvent = obj.event; 
				var tr = obj.tr; 
				sessionStorage.setItem("newsType", JSON.stringify(data));
				if (layEvent === 'del') { 
					layer.confirm('真的删除行么', function(index) {
						layer.close(index);
						$.post("http://localhost:8080/DogHome/sinfoServlet?md=delNewsinfo ",
								{
									id : data.newsinfoid
								}, function(res) {
									if (res.success) {

										obj.del();
										layer.msg('删除成功', {
											icon : 1,
											time : 1500
										});
									} else {

										layer.msg('删除失败,' + res.message, {
											icon : 2,
											time : 1500
										});
									}

								}, "json")
					});
				} else if (layEvent === 'edit') {
					var id = data.newsinfoid;

					var index = layui.layer.open({
						title : "编辑类型",
						type : 2,
						content : "activityUpdate.html",
						success : function(layero, index) {
							layui.layer.tips('点击此处返回类型列表',
									' .layui-layer-close', {
										tips : 3
									});
						},
						end : function() {
							location.reload();
						}
					})

					$(window).resize(function() {
						layui.layer.full(index);
					})
					layui.layer.full(index);

				}
			});
			$(".linksAdd_btn").click(
					function() {
						var index = layui.layer.open({
							title : "添加活动",
							type : 2,
							content : "activityAdd.html",
							success : function(layero, index) {
								layui.layer.tips('点击此处返回类型师列表',
										' .layui-layer-close', {
											tips : 3
										});
							},
							end : function() {
								location.reload();
							}
						})
						$(window).resize(function() {
							layui.layer.full(index);
						})
						layui.layer.full(index);
					})
		})
	</script>


</body>
</html>